package school;

public class Student {
    private String studentId;
    private String studentName;
    private String gender;
    private Course selectedCourse; // 所选课程

    public Student(String studentId, String studentName, String gender) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.gender = gender;
    }

    // 学生选课方法
    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println(studentName + " 学生选择了课程: " + course.getCourseName());
    }

    // 学生退课方法
    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println(studentName + " 学生退选了课程: " + selectedCourse.getCourseName());
            selectedCourse = null;
        } else {
            System.out.println(studentName + " 学生当前没有选课，无法退课");
        }
    }

    // 打印学生课表方法
    public void printCourseSchedule() {
        if (selectedCourse != null) {
            System.out.println("学生 " + studentName + " 的课表:");
            System.out.println(selectedCourse + ", 授课教师: " + (selectedCourse.getTeacherId() != null ? getTeacherNameByCourse(selectedCourse) : "暂无"));
        } else {
            System.out.println("学生 " + studentName + " 目前没有选课");
        }
    }

    // 辅助方法，根据课程获取教师姓名
    private String getTeacherNameByCourse(Course course) {
        // 这里假设教师编号为 "T001" 的教师是张三
        if ("T001".equals(course.getTeacherId())) {
            return "张三";
        }
        return "未知教师";
    }

    // Getter 和 Setter 方法
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Course getSelectedCourse() {
        return selectedCourse;
    }
}
